<?php
namespace Topxia\WebBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Filesystem\Filesystem;
use Topxia\Service\Util\CloudClientFactory;


class TestController extends BaseController
{
    public function indexAction(Request $request)
    {
        $a = array(
            '[25/Jul/2014:08:45:00 +0800]' =>  'eyJjb252ZXJ0b3IiOiJITFNWaWRlbyIsImNvbnZlcnRDYWxsYmFjayI6Imh0dHA6XC9cL3d4LjU1MjgwLmNvbVwvdXBsb2FkZmlsZVwvY2xvdWRfY29udmVydGNhbGxiYWNrMiIsImNvbnZlcnRQYXJhbXMiOnsiY29udmVydG9yIjoiSExTVmlkZW8iLCJzZWd0aW1lIjoxMCwidmlkZW9RdWFsaXR5IjoiaGlnaCIsImF1ZGlvUXVhbGl0eSI6ImhpZ2giLCJ2aWRlbyI6WyI2NDBrIiwiMTAwMGsiLCIxNTAwayJdLCJhdWRpbyI6WyI2NGsiLCI5NmsiLCIxMjhrIl19LCJkdXJhdGlvbiI6MTgwMDAsInVzZXIiOiIyIn0%3D',
            '[25/Jul/2014:08:49:23 +0800]' =>  'eyJjb252ZXJ0b3IiOiJITFNWaWRlbyIsImNvbnZlcnRDYWxsYmFjayI6Imh0dHA6XC9cL3d4LjU1MjgwLmNvbVwvdXBsb2FkZmlsZVwvY2xvdWRfY29udmVydGNhbGxiYWNrMiIsImNvbnZlcnRQYXJhbXMiOnsiY29udmVydG9yIjoiSExTVmlkZW8iLCJzZWd0aW1lIjoxMCwidmlkZW9RdWFsaXR5IjoiaGlnaCIsImF1ZGlvUXVhbGl0eSI6ImhpZ2giLCJ2aWRlbyI6WyI2NDBrIiwiMTAwMGsiLCIxNTAwayJdLCJhdWRpbyI6WyI2NGsiLCI5NmsiLCIxMjhrIl19LCJkdXJhdGlvbiI6MTgwMDAsInVzZXIiOiIyIn0%3D',
            '[25/Jul/2014:08:55:43 +0800]' =>  'eyJjb252ZXJ0b3IiOiJITFNWaWRlbyIsImNvbnZlcnRDYWxsYmFjayI6Imh0dHA6X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iMTAwMGsiLCIxNTAwayJdLCJhdWRpbyI6WyI2NGsiLCI5NmsiLCIxMjhrIl19LCJkdXJhdGlvbiI6MTgwMDAsInVzZXIiOiIyIn0%3D',
            '[25/Jul/2014:09:08:56 +0800]' =>  'eyJjb252ZXJ0b3IiOiJITFNWaWRlbyIsImNvbnZlcnRDYWxsYmFjayI6Imh0dHA6XC9cL3d4LjU1MjgwLmNvbVwvdXBsb2FkZmlsZVwvY2xvdWRfY29udmVydGNhbGxiYWNrMiIsImNvbnZlcnRQYXJhbXMiOnsiY29udmVydG9yIjoiSExTVmlkZW8iLCJzZWd0aW1lIjoxMCwidmlkZW9RdWFsaXR5IjoibG93IiwiYXVkaW9RdWFsaXR5IjoibG93IiwidmlkZW8iOlsiMjQwayIsIjQ0MGsiLCI2NDBrIl0sImF1ZGlvIjpbIjMyayIsIjQ4ayIsIjY0ayJdfSwiZHVyYXRpb24iOjE4MDAwLCJ1c2VyIjoiMyJ9',
            '[25/Jul/2014:09:09:01 +0800]' =>  'eyJjb252ZXJ0b3IiOiJITFNWaWRlbyIsImNvbnZlcnRDYWxsYmFjayI6Imh0dHA6XC9cL3d4LjU1MjgwLmNvbVwvdXBsb2FkZmlsZVwvY2xvdWRfY29udmVydGNhbGxiYWNrMiIsImNvbnZlcnRQYXJhbXMiOnsiY29udmVydG9yIjoiSExTVmlkZW8iLCJzZWd0aW1lIjoxMCwidmlkZW9RdWFsaXR5IjoibG93IiwiYXVkaW9RdWFsaXR5IjoibG93IiwidmlkZW8iOlsiMjQwayIsIjQ0MGsiLCI2NDBrIl0sImF1ZGlvIjpbIjMyayIsIjQ4ayIsIjY0ayJdfSwiZHVyYXRpb24iOjE4MDAwLCJ1c2VyIjoiMyJ9',
            '[25/Jul/2014:09:09:03 +0800]' =>  'eyJjb252ZXJ0b3IiOiJITFNWaWRlbyIsImNvbnZlcnRDYWxsYmFjayI6Imh0dHA6XC9cL3d4LjU1MjgwLmNvbVwvdXBsb2FkZmlsZVwvY2xvdWRf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LCJkdXJhdGlvbiI6MTgwMDAsInVzZXIiOiIyIn0%3D',
            '[25/Jul/2014:09:31:53 +0800]' =>  'eyJjb252ZXJ0b3IiOiJITFNWaWRlbyIsImNvbnZlcnRDYWxsYmFjayI6Imh0dHA6XC9cL3d4LjU1MjgwLmNvbVwvdXBsb2FkZmlsZVwvY2xvdWRfY29udmVydGNhbGxiYWNrMiIsImNvbnZlcnRQYXJhbXMiOnsiY29udmVydG9yIjoiSExTVmlkZW8iLCJzZWd0aW1lIjoxMCwidmlkZW9RdWFsaXR5IjoibG93IiwiYXVkaW9RdWFsaXR5IjoibG93IiwidmlkZW8iOlsiMjQwayIsIjQ0MGsiLCI2NDBrIl0sImF1ZGlvIjpbIjMyayIsIjQ4ayIsIjY0ayJdfSwiZHVyYXRpb24iOjE4MDAwLCJ1c2VyIjoiMyJ9',
            '[25/Jul/2014:09:31:54 +0800]' =>  'eyJjb252ZXJ0b3IiOiJITFNWaWRlbyIsImNvbnZlcnRDYWxsYmFjayI6Imh0dHA6XC9cL3d4LjU1MjgwLmNvbVwvdXBsb2FkZmlsZVwvY2xvdWRfY29udmVydGNhbGxiYWNrMiIsImNvbnZlcnRQYXJhbXMiOnsiY29udmVydG9yIjoiSExTVmlkZW8iLCJzZWd0aW1lIjoxMCwidmlkZW9RdWFsaXR5IjoibG93IiwiYXVkaW9RdWFsaXR5IjoibG93IiwidmlkZW8iOlsiMjQwayIsIjQ0MGsiLCI2NDBrIl0sImF1ZGlvIjpbIjMyayIsIjQ4ayIsIjY0ayJdfSwiZHVyYXRpb24iOjE4MDAwLCJ1c2VyIjoiMyJ9',
            '[25/Jul/2014:09:31:55 +0800]' =>  'eyJjb252ZXJ0b3IiOiJITFNWaWRlbyIsImNvbnZlcnRDYWxsYmFjayI6Imh0dHA6XC9cL3d4LjU1MjgwLmNvbVwvdXBsb2FkZmlsZVwvY2xvdWRfY29udmVydGNhbGxiYWNrMiIsImNvbnZlcnRQYXJhbXMiOnsiY29udmVydG9yIjoiSExTVmlkZW8iLCJzZWd0aW1lIjoxMCwidmlkZW9RdWFsaXR5IjoibG93IiwiYXVkaW9RdWFsaXR5IjoibG93IiwidmlkZW8iOlsiMjQwayIsIjQ0MGsiLCI2NDBrIl0sImF1ZGlvIjpbIjMyayIsIjQ4ayIsIjY0ayJdfSwiZHVyYXRpb24iOjE4MDAwLCJ1c2VyIjoiMyJ9',
        );

foreach ($a as $k => $v) {
    print_r($k);
    echo " ";
    print_r(base64_decode($v));

    echo "\n";

}

exit();










        $result = $this->getCloudClient()->checkKey();

        var_dump($result);exit();

    }

    public function getConnection()
    {
        return $this->container->get('doctrine.dbal.default_connection');
    }

    protected function isFieldExist($table, $filedName)
    {
        $sql = "DESCRIBE `{$table}` `{$filedName}`;";
        $result = $this->getConnection()->fetchAssoc($sql);
        return empty($result) ? false : true;
    }

    private function getCourseService()
    {
        return $this->getServiceKernel()->createService('Course.CourseService');
    }

    private function getCloudClient()
    {
        if(empty($this->cloudClient)) {
            $factory = new CloudClientFactory();
            $this->cloudClient = $factory->createClient();
        }
        return $this->cloudClient;
    }
    
}